package com.crimax.lanproj.properties;

import java.util.ArrayList;
import java.util.List;

/*
 * Comparable object that represent a loan supplier.
 */
public class LoanProperties {

	private String name;
	private String friendlyName;
	private String bank;
	private String useUC;
	private String weekendPayment;
	private String URL;
	private String imageSource;
	private String age;
	private String ba;
	private String eleg;
	private String epost;
	private String uc;
	private String freeAmount;
	private String freeTime;
	
	private float interest=0;
	private int maxSize;
	private int minSize;
	private int maxYear;
	private int minYear;
	
	private List<PriceObject> price30 = new ArrayList<PriceObject>();
	private List<PriceObject> price60 = new ArrayList<PriceObject>();
	private List<PriceObject> price90 = new ArrayList<PriceObject>();

	
	
	public int getBigTotal(int length, int amount){
		
		double monthlyPayment = this.getMonthlyPayment(amount, length);
		return (int) (monthlyPayment*(length*12));

	}
	
	public double getMonthlyPayment(double loanAmount, double numberYears) {
		
		double monthlyInterest = interest/1200;
		double monthlyRepayment = loanAmount* monthlyInterest/(1-(Math.pow(1+monthlyInterest, -numberYears*12)));
		return monthlyRepayment;
	}
	
	public int getBigFee(int length, int amount){
		return this.getBigTotal(length, amount)-amount;

	}

	public String getFreeTime() {
		return freeTime;
	}

	public void setFreeTime(String freeTime) {
		this.freeTime = freeTime;
	}

	public String getFreeAmount() {
		return freeAmount;
	}

	public void setFreeAmount(String freeAmount) {
		this.freeAmount = freeAmount;
	}

	public String getUc() {
		return uc;
	}

	public void setUc(String uc) {
		this.uc = uc;
	}

	public int getMaxYear() {
		return maxYear;
	}

	public void setMaxYear(int maxYear) {
		this.maxYear = maxYear;
	}

	public int getMinYear() {
		return minYear;
	}

	public void setMinYear(int minYear) {
		this.minYear = minYear;
	}
	
	public String getFriendlyName() {
		return friendlyName;
	}

	public void setFriendlyName(String friendlyName) {
		this.friendlyName = friendlyName;
	}

	public boolean isQualifiedAmount(int amount, int year){
		
		// both zero on max years i always qualified
		
		
		if(this.maxSize >= amount && this.minSize <= amount ){
			
			if(this.maxYear==0 && this.minYear==0){
				return true;
			}
			
			if(this.maxYear >= year && this.minYear <= year){
				return true;
			}
			
			return false;
		}
		
		return false;
		
	}
	
	public float getInterest() {
		return interest;
	}
	public void setInterest(float interest) {
		this.interest = interest;
	}
	public int getMaxSize() {
		return maxSize;
	}
	public void setMaxSize(int maxSize) {
		this.maxSize = maxSize;
	}
	public int getMinSize() {
		return minSize;
	}
	public void setMinSize(int minSize) {
		this.minSize = minSize;
	}
	public void setPrice30(List<PriceObject> price30) {
		this.price30 = price30;
	}
	public void setPrice60(List<PriceObject> price60) {
		this.price60 = price60;
	}
	public void setPrice90(List<PriceObject> price90) {
		this.price90 = price90;
	}
	public String getEpost() {
		return epost;
	}
	public void setEpost(String epost) {
		this.epost = epost;
	}
	public String getWeekendPayment() {
		return weekendPayment;
	}
	public void setWeekendPayment(String weekendPayment) {
		this.weekendPayment = weekendPayment;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getBank() {
		return bank;
	}
	public void setBank(String bank) {
		this.bank = bank;
	}
	public String getUseUC() {
		return useUC;
	}
	public void setUseUC(String useUC) {
		this.useUC = useUC;
	}
	public List<PriceObject> getPrice30() {
		return price30;
	}
	public List<PriceObject> getPrice60() {
		return price60;
	}
	public List<PriceObject> getPrice90() {
		return price90;
	}
	public String getURL() {
		return URL;
	}
	public void setURL(String uRL) {
		URL = uRL;
	}
	public String getImageSource() {
		return imageSource;
	}
	public void setImageSource(String imageSource) {
		this.imageSource = imageSource;
	}
	public String getAge() {
		return age;
	}
	public void setAge(String age) {
		this.age = age;
	}
	public String getBa() {
		return ba;
	}
	public void setBa(String ba) {
		this.ba = ba;
	}
	public String getEleg() {
		return eleg;
	}
	public void setEleg(String eleg) {
		this.eleg = eleg;
	}
}
